package com.huixh.train.common.resp;

/**
 * @author huixh
 */
public class Result<T> {
    private boolean success;

    private String message;

    private T data;

    public Result() {
    }

    public static <T> Result<T> success() {
        return new Result<>(true, "success", null);
    }

    public static <T> Result<T> success(String msg) {
        return new Result<>(true, msg, null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(true, "success", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(true, message, data);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<>(false, message, null);
    }

    public Result(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }


    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                ", success=" + success +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

}
